package com.pipe.servicepipe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pipe.servicepipe.entity.PipeLog;
import com.pipe.servicepipe.entity.vo.PipeLogQuery;
import com.pipe.servicepipe.mapper.PipeLogMapper;
import com.pipe.servicepipe.service.PipeLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 日志表 服务实现类
 * </p>
 *
 * @author hetao
 * @since 2020-07-12
 */
@Service
public class PipeLogServiceImpl extends ServiceImpl<PipeLogMapper, PipeLog> implements PipeLogService {

    @Override
    public void findByPage(PipeLogQuery query, Page<PipeLog> page) {
        QueryWrapper<PipeLog> wrapper = new QueryWrapper();
        if (query != null) {
            String operator = query.getOperator();
            String startTime = query.getStartTime();
            String endTime = query.getEndTime();
            if (StringUtils.isNotEmpty(operator)) {
                wrapper.like("operator",operator);
            }
            if (StringUtils.isNotEmpty(startTime)) {
                wrapper.ge("create_time",startTime);
            }
            if (StringUtils.isNotEmpty(endTime)) {
                wrapper.le("create_time",endTime);
            }
        }
        this.baseMapper.selectPage(page, wrapper);
    }
}
